package com.interview.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexValidation {

    public static boolean isValid(String REGEX,String inputStr) {
        Pattern pattern = Pattern.compile(REGEX);
        // 创建Matcher对象
        Matcher matcher = pattern.matcher(inputStr);
        // 使用matches方法验证整个字符串是否匹配正则表达式
        return matcher.matches();
    }

    public static void main(String[] args) {
        System.out.println(RegexValidation.isValid("^[A-Z](,[A-Z])*$", "A,B"));
    }
}
